import static org.junit.Assert.*;

import java.util.Arrays;

import org.junit.Test;



public class StirngArray {
	
	@Test
	 public void testPlus() {
        String s = "";
        long ts = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            s = s + String.valueOf(i);
        }
        long te = System.currentTimeMillis();
        System.out.println("+ cost {} ms:"+(te-ts));

    }
	@Test
	public void testStringBuffer() {
        StringBuffer sb = new StringBuffer();
        long ts = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            sb.append(String.valueOf(i));
        }
        sb.toString();
        long te = System.currentTimeMillis();
        System.out.println("StringBuffer cost {} ms:"+(te-ts));

}
	@Test
	public void ArrayTester(){
		int []arr = {5,6,1,4,3,2};
		Arrays.sort(arr);
		assertEquals(4, arr[3]);
	}
	
	    String teststring1 = "Hello World!";
	    String teststring2 = " ";

	    String teststring3 = "123|qwe|456";
	    String[] teststring4 = new String[3];
	    String[] teststring5 = new String[3];

	    @Test
	    public void StringTester()  {
	        assert teststring1.charAt(0) == 'H' : "error1:charAt";
	        assert teststring1.charAt(teststring1.length()-1) == '!' : "error2:charAt";
	        assert teststring2.charAt(0) == teststring2.charAt(teststring2.length()-1) : "error3:charAt";

	        teststring4 = teststring3.split("\\|");
	        teststring5 = teststring3.split("o");

	        assert teststring4[0].equals("123") : "error4:split";
	        assert teststring4[1].equals("qwe") : "error5:split";
	        assert teststring4[2].equals("456"): "error6:split";


	
	    }
}